package com.dmap.userportrait.controller.background;

import com.dmap.base.vo.BaseVo;
import com.dmap.userportrait.rpc.UserMovementRpc;
import com.dmap.userportrait.utils.CreateJsonFileUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @Author liuying
 * @Description 用户运动信息汇总控制层
 * @Date 19:24 2018/6/27
 */
@Api(value = "用户画像/用户运动信息", description = "用户画像/用户运动信息")
@RestController
@RequestMapping(value = "/background/dmap-user-portrait-server/v1/userPortrait")
public class UserMovementContraller {
    @Resource
    private UserMovementRpc userMovementRpc;

    @ResponseBody
    @ApiOperation(value = "查询用户运动信息", notes = "查询用户运动信息")
    @RequestMapping(value = "/select/selectUserMovementInfo", method = RequestMethod.GET)
    public BaseVo selectUserMovementInfo(@RequestParam Long userId, @RequestParam String filePath, @RequestParam String fileName) {
        BaseVo baseVo = new BaseVo();

        //得到用户运动信息json字符串
        String infoString = userMovementRpc.selectUserMovementInfo(userId);

        //输出文件
        boolean flag = CreateJsonFileUtil.createJsonFile(infoString, filePath, fileName);

        baseVo.setData(flag);
        return baseVo;
    }
}
